Host based satellite positioning systems

ABSTRACT

Methods and systems consistent with the present invention provide a host based positioning system. The host based positioning system includes a tracker hardware interface that connects to a dedicated hardware space vehicle tracker. The tracker hardware interface receives positioning information from the space vehicle tracker. The host based positioning system also includes a memory that includes a GPS library having a user interface, a tracker interface, and an operating system interface. A processor runs functions provided by the interfaces.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.11/149,438, entitled HOST BASED SATELLITE POSITIONING SYSTEMS, filedJun. 6, 2005 which is a continuation of U.S. patent application Ser. No.10/269,914, entitled HOST BASED SATELLITE POSITIONING SYSTEMS, filed onOct. 10, 2002, that issued as U.S. Pat. No. 7,043,363 on May 9, 2006,which was related to U.S. patent application Ser. No. 10/269,105,titled, “LAYERED HOST BASED SATELLITE POSITIONING SOLUTIONS”, filed onOct. 10, 2002, and U.S. patent application Ser. No. 10/269,104, titled,“NAVIGATION PROCESSING IN HOST BASED SATELLITE POSITIONING SOLUTIONS”,filed Oct. 10, 2002, both of which were incorporated by reference intheir entirety and which are also incorporated by reference herein.

BACKGROUND OF THE INVENTION

1. Field of the Invention

This invention relates to satellite positioning systems. In particular,this invention relates to satellite positioning systems implementedutilizing the processing power of a host in communication with ahardware tracker.

2. Related Art

The worldwide utilization of wireless devices such as two-way radios,pagers, portable televisions, personal communication system (“PCS”),personal digital assistants (“PDAs”) cellular telephones (also known a“mobile phones”), Bluetooth, satellite radio receivers and SatellitePositioning Systems (“SPS”) such as Global Positioning Systems (“GPS”),also known as NAVSTAR, is growing at a rapid pace. Current trends arecalling for the incorporation of SPS services into a broad range ofelectronic devices and systems, including Personal Digital Assistants(PDAs), cellular telephones, portable computers, automobiles, and thelike. At the same time, manufacturers constantly strive to reduce costsand produce the most cost-attractive product possible for consumers.

In the past, providing a SPS solution often involved expensive dedicatedSPS signal reception and processing hardware, as well as dedicated postprocessing hardware for resolving location measurements, displayinglocation coordinates, updating map displays, and the like. However,given the rapid growth in speed, sophistication, and'processing power ofthe host microprocessors present in the host device (e.g., in a cellulartelephone or automobile), the possibility exists for allowing the hostmicroprocessor to bear the burden not only of running its regularapplications, but also to operate as part of the SPS solution. Such anapproach is presented in U.S. Pat. No. 6,430,503, titled “DistributedGPS Navigation System,” issued to Paul W. McBurney et al., the entiretyof which is incorporated herein by reference.

As noted above, however, there is a strong push toward incorporating SPSsolutions in many electronic devices designed by numerous manufacturers.Of course, each device varies considerably in architecture, operatingsystem, hardware interfaces, and the like. Prior SPS solutions did notprovide the flexibility that allowed the solutions to be adapted to awide range of electronic devices. Instead, expensive customizedsolutions were needed for each device, thereby undesirably increasingcosts and delaying the introduction of SPS services into a wide range ofdevices.

Therefore, a need exists for implementations of SPS solutions thatovercome the problems noted above and others previously experienced.

SUMMARY

Methods and systems consistent with an invention of a host based SPSsolution are disclosed. The SPS solution is implemented in a convenientlibrary form that is flexible and extensible, and that may adapt to meethe needs of many different hardware platforms. As a result, a widevariety of electronic devices may incorporate SPS functionality withless expense utilizing less development time.

In one example implementation, a host based SPS system may include ahost processing system that connects through a tracker hardwareinterface to a dedicated hardware space vehicle tracker. The hostprocessing system may also include a memory that includes a SPS libraryhaving a user interface, positioning engine, a tracker interface and anoperating system interface. A processor in the host processing systemruns the positioning engine and the functions provided by theinterfaces.

The tracker hardware interface receives positioning information from thespace vehicle tracker. Through functions in the tracker interface, thepositioning information is communicated to the positioning engine. Inturn, the positioning engine may determine a position and communicatethe position to a user application through functions provided in theuser interface.

Other apparatus, systems, methods, features and advantages of thepresent invention will be or will become apparent to one with skill inthe art upon examination of the following figures and detaileddescription. It is intended that all such additional systems, methods,features and advantages be included within this description, be withinthe scope of the present invention, and be protected by the accompanyingclaims.

BRIEF DESCRIPTION OF THE FIGURES

The components in the figures are not necessarily to scale, emphasisinstead being placed upon illustrating the principles of the invention.In the figures, like reference numerals designate corresponding partsthroughout the different views.

FIG. 1 illustrates a detailed block diagram of one example of apositioning systems implemented as a host based SPS solution.

FIG. 2 illustrates a hardware tracker that communicates with thepositioning system shown in FIG. 1.

FIG. 3 depicts a hardware and software diagram of a positioning systemthat includes a GPS library with a user interface, a tracker interface,and an operating system interface.

FIG. 4 illustrates a flow diagram of a user program running in thepositioning system.

FIG. 5 illustrates a block diagram of the cooperation between threads,tasks and hardware in one implementation of a host based SPS solution.

FIG. 6 illustrates an execution schedule for a receive manager threadand a periodic navigation task.

FIG. 7 illustrates a synchronization diagram for the timing andinteraction between the threads and tasks shown in FIG. 5.

DETAILED DESCRIPTION

Reference will now be made in detail to an implementation in accordancewith methods, systems, and products consistent with the presentinvention as illustrated in the accompanying drawings. The samereference numbers may be used throughout the drawings and the followingdescription to refer to the same or like parts.

A typical satellite positioning system (“SPS”) system has approximately12 satellites that may be visible at any one time to a wireless device.SPS means any system utilizing satellites and/or land-basedcommunications devices for providing or enabling the determination of alocation of the wireless device on the earth, for example but notlimited to: the global positioning system (“GPS”) known as NAVSTAR,GLONASS, LORAN, Shoran, Decca, or TACAN. Although many of the interfacefunctions below make reference to GPS, those functions are not limitedto use with GPS, but, generally, are equally applicable in other SPSenvironments.

FIG. 1 depicts a block diagram of a positioning system 100 suitable forpracticing methods and implementing systems consistent with the presentinvention. The positioning system 100 includes a host 102 and trackerhardware 104. The host 102 includes a central processing unit (“CPU”)106, a hardware tracker interface 110, and a memory 112. The host 102also includes a secondary storage device 114 (e.g., generallynon-volatile memory such as a magnetic disk, flash memory, opticalstorage, and the like), and a display 116, and an input interface 118(e.g., a mouse, keyboard, and the like).

An operating system 120 (e.g., Windows CE, QNX, Palm OS, UNIX, Linux,Windows 2000, NT, XP, or the like) runs in the memory 112. As will beexplained in more detail below, a user program 122 communicates with aSPS library 124 and the operating system 120. The user program 122thereby receives position information from the GPS library, and may alsocommunicate commands to the SPS library. The user program 122 may be anyprogram that utilizes positioning information, including, as examples, amapping program, course charter, location aid, and the like.

The host 102 connects through the hardware tracker interface 110 and theinterface connection 126 to the tracker hardware 104. The hardwaretracker interface 110 may be virtually any type of data transferinterface (as examples, a serial, parallel, compact flash, PC Card, ornetwork interface). The interface connection 126 may then be, asexamples, a serial cable, parallel cable, or network cable, and mayoptionally be wireless. In one implementation, the hardware trackerinterface 110 is an RS232 port running at 38,400 bps, N-8-1 thatcommunicates up to 2 KB of data per second between the host 102 and thetracker hardware 104.

In other implementations, the tracker hardware (as illustrated by thereference numeral 128) is more closely incorporated into the host 102.Thus, rather than connecting to the host 102 through the interfaceconnection 126, for example, the tracker hardware 128 may be directlycoupled to the host 102 address, data, and control buses. As will beexplained in more detail below, the host 102 receives and processesnavigation information from the hardware tracker 104, 128 in order toprovide the user programs 122 with position information.

Although aspects of the present invention are depicted as being storedin memory 112, one skilled in the art will appreciate that all or partof systems and methods consistent with the present invention may bestored on or read from other machine-readable media, for example,secondary storage devices such as hard disks, floppy disks, and CD-ROMs;a signal received from a network; or other forms of ROM or RAM eithercurrently known or later developed. Further, although specificcomponents of positioning system 100 are described, one skilled in theart will appreciate that a positioning system suitable for use withmethods, systems, and articles of manufacture consistent with thepresent invention may contain additional or different components. Forexample, the CPU 106 may be a microprocessor, microcontroller,application specific integrated circuit (“ASIC”), discrete or acombination of other types of circuits acting as a central processingunit. The memory 112 may be RAM, DRAM, SDRAM, or any other type ofread/writeable memory.

Turning next to FIG. 2, that figure shows one example of animplementation of the tracker hardware 104. The tracker hardware 104acquires and tracks SPS satellites and sends raw measurement data to thehost 102 for position calculation. To that end, the tracker hardware 104includes an antenna 202 for receiving SPS satellite signals and a radiofrequency (“RF”) filter 204 for passing the signals to the RF interfacecircuit 206. The RF interface circuit 206 processes the signals,produces 2-bit Inphase and Quadrature (“I/Q”) signals and recovers SPSclocks. The RF interface circuit 206 provides the I/Q signals and SPSclocks to the location processing circuit 208 for digital processing. Areference frequency source 210 (e.g., a crystal oscillator) provides areference clock for the RF interface circuit 206, while the optionalreal time clock (“RTC”) source 212 provides a reference clock for thelocation processing circuit 208.

The tracker hardware 104 may be implemented with components availablefrom SiRF Technology, Inc. of San Jose Calif. For example, the RFinterface circuit 206 may be implemented as a GRF2i/LP integratedcircuit. The location processing circuit may be implemented, asexamples, as a GSP2t integrated circuit or GSP2e integrated circuit. Thetracker hardware 104 minimizes the overhead on the host 102 andoperating system 120 by keeping low the maximum transmission rate of rawmeasurements to the host 102 (e.g., one measurement per second).

With regard next to FIG. 3, that figure shows a detailed block diagramof a hardware and software diagram 300 for the positioning system 100.The memory 112 in the host 102 includes a SPS library 124, user programs122 (e.g., map displaying, map matching, dead reckoning and routecalculation programs), and the operating system 120 (which may be amulti-threaded operating system). The SPS library 124 includes apositioning engine 302, a user interface 304, a tracker interface 306,and an operating system interface 308. The user tasks 310 implementdevice drivers or link directly to the user programs 122, as examples.

In addition to the hardware tracker 104, persistent storage 312 and areal time clock 314 may optionally be provided. The persistent storage312 may be, as examples, 2 KB of Flash memory, battery backed up RAM ora disk drive. The SPS library 124 may use the RTC in the host 102, theRTC 314, or may operate without an RTC.

The user interface 304 is called by the user programs 122 to start andconfigure the positioning system. The positioning engine 302 calls afunction provide by the user program 122 (e.g., GPS_Output) to deliverpositioning messages (e.g., position updates and other synchronous andasynchronous data) to the user program 122. The tracker interface 306′provides for communication between the tracker hardware 104 and the host102 and, to that end, may load and call the operating system 120 serialcommunication drivers. The operating system interface 308 callsoperating system functions for task scheduling and synchronization, RTCaccess, and storage access.

FIG. 4 shows a flow diagram of a user program 122. The user program 122calls GPS_Start to start the positioning engine 302 (step 402). The userprogram 122 determines whether to configure the positioning engine 302(step 404). The program 122 configures the positioning engine 302 bysending a message to the positioning engine 302 using the GPS_Inputfunction, for example (step 406). Next, the program 122 waits for a newposition fix (or other information) from the positioning engine 302(step 408).

When information is received, the user program 122 processes theinformation, for example, to display or update a map (step 410). If theprogram 122 continues to run (step 412), processing returns to step 404.Otherwise, the program 122 stops the positioning engine (step 414) andterminates. The positioning engine runs separately and, when newpositioning information is available, creates a message for the program122 (step 416) and sends the message to the program 122 (step 418).Tables 1-5 below show exemplary function calls.

TABLE 1 GPS_Start( ) /* Starts GPS Engine tasks, initial acquisitionbegins: */ tGPS_UINT32        result; result = GPS_Start (       GPS_CTRL_MODE_AUTO,   /* default - hot start */        0, /* usedefault clock offset */        1, /* use port 1 */        38400 /* baudrate */       );

TABLE 2 User Callback GPS_Output( ) /* User callback function. Receivesall communication from GPS. */ #include “GPS_interface.h” voidGPS_Output(   tGPS_UINT32 message_id,   void *    message_structure,  VtGPS_UINT32  length ) {   tGPS_NAV_MEASURED_NAVIGATION nav_data;  switch ( message_id )  {     case GPS_NAV_MEASURED_NAVIGATION:     memcpy( &nav_data, message_structure,sizeof(tGPS_NAV_MEASURED_NAVIGATION) );     if ( nav_data.nav_mode &GPS_MODE_MASK )      {      printf(“x=%ld, y=%ld, z=%ld \n”,          nav_data.ecef_x, nav_data.ecef_y,           nav_data.ecef_z);     else        printf(“no fix \n”);      break;     caseGPS_NAV_MEASURED_TRACKER:      /*...*/      break;     default:     /*...*/      break;   } // switch } // GPS_Output( )

TABLE 3 Configure using GPS_Input( ) /* Configures GPS Engine to turnoff SBAS correction: */    tGPS_NAV_SET_DGPS_SOURCE  DGPSSrc;   tGPS_UINT32        result;    DGPSSrc.bit_rate = 0;    DGPSSrc.freq =0;    DGPSSrc.src = GPS_DGPS_SRC_NONE;    result = GPS_Input(GPS_NAV_SET_DGPS_SOURCE, (void*)&DGPSSrc, sizeof(DGPSSrc) );

TABLE 4 Configure using GPS_Input( )  /* Forces cold start of GPSreceiver: */  tGPS_NAV_INITIALIZE      InitMsg; tGPS_UINT32        result;  memset(&InitMsg, 0, sizeof(InitMsg));InitMsg.restart_flags = GPS_RESTART_COLD;  result = GPS_Input(  GPS_NAV_INITIALIZE, (void*)&InitMsg,  sizeof(InitMsg) );

TABLE 5 GPS_Stop( ) /* Stops GPS Engine and all SiRFNav tasks: */tGPS_UINT32        result; result = GPS_Stop( );

Below, one exemplary implementation of the user interface 304, trackerinterface 306, and an operating system interface 308 is set forth. Table6 shows which functions and messages are associated with each interface,while Tables 7-10 set forth files and data types used or referred to inthe follow description.

TABLE 6 Interface Functions and Messages User Interface: GPS_Start( )GPS_Stop( ) GPS_Output( ) GPS_Input( ) GPS_NAV_MEASURED_NAVIGATIONoutput message GPS_NAV_MEASURED_TRACKER output messageGPS_NAV_SW_VERSION output message GPS_NAV_CLOCK_STATUS output messageGPS_NAV_ERROR output message GPS_ADC_ODOMETER_DATA output messageGPS_NAV_COMPLETE output message GPS_NAV_TEXT output messageGPS_NAV_INITIALIZE input message GPS_NAV_POLL_SW_VERSION input messageGPS_NAV_SET_DGPS_SOURCE input message GPS_NAV_POLL_CLOCK_STATUS inputmessage GPS_NAV_SET_SBAS_PRN input message Operating system interface:OS_Thread_Create( ) OS_Thread_Delete( ) OS_Thread_Sleep( )OS_Mutex_Create( ) OS_Mutex_Delete( ) OS_Mutex_Enter( ) OS_Mutex_Exit( )OS_Semaphore_Create( ) OS_Semaphore_Delete( ) OS_Semaphore_Wait( )OS_Semaphore_Release( ) OS_Storage_Open( ) OS_Storage_Close( )OS_Storage_Write( ) OS_Storage_WriteAll( ) OS_Storage_Read( )OS_RTC_Read( ) Tracker interface: GPS_COMM_TRK_Create( )GPS_COMM_TRK_Delete( ) GPS_COMM_TRK_Open( ) GPS_COMM_TRK_Reopen( )GPS_COMM_TRK_Close( ) GPS_COMM_TRK_Wait( ) GPS_COMM_TRK_Read( )GPS_COMM_TRK_Write( )

TABLE 7 Include file Description gps_types.h Type definitions used inGPS library interfaces gps_rtos.h Definitions and prototypes of the GPSoperating system interface gps_ctrl.h Definitions and prototypes of theGPS control interface gps_interface.h Definitions and prototypes of theGPS communication interface gps_messages.h Definitions and structuredefines of messages used by the communication interface gps_comm_trk.hDefinitions and prototypes of the tracker communication interfacegps_proto_sirfbinary.h Definitions and prototypes of the binary serialprotocol gps_debug.h Definitions for development and debugging

TABLE 8 Source file Description gps_rtos.c Contains implementation ofthe GPS operating system interface gps_comm_trk.c Containsimplementation of the tracker communication interface

TABLE 9 Library file Description SiRFNavServer.lib GPS receiver library

TABLE 10 Data Types Type name Data range Defined as tGPS_SINT8 −128 . .. 127 signed char tGPS_UINT8 0 . . . 255 unsigned char tGPS_SINT16−32768 . . . 32767 signed short tGPS_UINT16 0 . . . 65535 unsigned shorttGPS_SINT32 −2147483648 . . . 2147483647 signed long tGPS_UINT32 0 . . .4294967295 unsigned long tGPS_HANDLE 32 bit pointer void *

The user or GPS interface includes a GPS control interface and a GPScommunication interface. The GPS control Interface functions allow auser program to start and stop the GPS engine using the functions shownin Table 11.

TABLE 11 Function Description Provided in GPS_Start( ) Starts GPS engineGPS library GPS_Stop( ) Stops GPS engine GPS library

The GPS communication interface functions allow a user program to sendand receive messages to and from the GPS engine using the functionsshown in Table 12.

TABLE 12 Function Description Provided in GPS_Output( ) Receives a datafrom the GPS user code engine GPS_Input( ) Send commands to the GPS GPSlibrary engine

GPS_Start( ) initializes and starts positioning engine threads andcommunication interface. This function should be called by user programsto start GPS activity.

TABLE 13 Include file   gps_ctrl.h Syntax   tGPS_RESULTGPS_Start(tGPS_UINT32 start_mode,       tGPS_UINT32 clock_offset,      tGPS_UINT32 port_num,       tGPS_UINT32 baud_rate ) Parameter Datarange Units Description start_mode Start configuration flags. See Table14below for details. clock_offset 0, 25000 . . . 146000 Hz Default GPSclock offset. This value is used by the factory start or when a savedvalue is not available. This value should reflect a tracker's hardwarepeculiarity. If zero is provided here a default value of 96250 Hz isused. port_num 1 . . . 64 Specifies a communication port where trackeris connected to. 1 = serial port 1, 2 = serial port 2, . . . baud_rate4800, 38400, 57600, bps Specifies a baud rate at 115200 which tracker isconnected to. Default 2t tracker baud rate is 38400 bps.

TABLE 14 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 Reserved. Write0 only. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Text ADC Reserved. Write 0only. Start type. See enable mode. below for allowed See values. below.

TABLE 15 Text Enable Value Macro Description 0 Development text messagesare disabled after start. Can be enabled later by GPS input message. 1GPS_CTRL_MODE_TEXT_ENABLE Enables development text messages right afterstart (via GPS_Output( ) function)

TABLE 16 ADC Mode Value Macro Description 0 ADC messages from trackerare disabled. 1 GPS_CTRL_MODE_ADC_ENABLE_1HZ Enables ADC message fromtracker at 1 Hz rate 2 GPS_CTRL_MODE_ADC_ENABLE_10HZ Enables ADC messagefrom tracker at 10 Hz rate 3 Reserved

TABLE 17 Start Type Value Macro Description 0 GPS_CTRL_MODE_AUTO GPSwill automatically choose a start mode accordingly to availability oftime, position and ephemeris information. This start mode should be usedfor normal operation. 1 GPS_CTRL_MODE_HOT For testing purposes only. GPSwill make a hot start. 2 GPS_CTRL_MODE_WARM For testing purposes only.GPS will make a warm start. 3 GPS_CTRL_MODE_COLD For testing purposesonly. GPS will make a cold start. 4 GPS_CTRL_MODE_FACTORY For testingpurposes only. GPS will make a factory cold start. All saved informationwill be deleted. 5 GPS_CTRL_MODE_TEST For SiRF internal testing purposesonly. Other value Reserved

TABLE 18 Return Values Return value Description GPS_SUCCESS GPS enginehas started successfully GPS_CTRL_ALREADY_STARTED Error: GPS engine isalready running GPS_CTRL_INVALID_MODE Error: invalid start modeGPS_CTRL_CLOCK_OFFSET_OUT_OF_RANGE Error: clock offset is out of rangeGPS_CTRL_ERROR_OPENING_PORT Error: could not open serial portGPS_CTRL_RTOS_ERROR Error creating OS objects (threads, semaphores,mutexes)

TABLE 19 Example #include “gps_types.h” #include “gps_ctrl.h” if (GPS_Start(GPS_CTRL_MODE_AUTO | GPS_CTRL_MODE_TEXT_ENABLE, 96250, 1,38400) != GPS_SUCCESS ) {   // error handler } // GPS engine has startedsuccessfully ...

The GPS_Stop function stops the positioning engine threads andcommunication interface. This function should be called by the userprogram to stop GPS activity.

Include file gps_ctrl.h Syntax tGPS_RESULT GPS_Stop( void ) Return valueDescription GPS_SUCCESS GPS engine has stopped successfullyGPS_CTRL_ALREADY_STOPPED Error: GPS engine is already stopped

TABLE 21 Example #include “gps_types.h” #include “gps_ctrl.h” if (GPS_Stop( ) != GPS_SUCCESS ) {    // error handler } // GPS engine hasstopped successfully ...

The GPS_Output function retrieves a message from positioning engine.There are no return values. The function is called by the positioningengine whenever any message is sent out. This function is implemented bythe user program and statically linked with the GPS library.

TABLE 22 Syntax void GPS_Output( tGPS_UINT32 message_id, void*message_structure, tGPS_UINT32 length ) Parameter Data range UnitsDescription message_id GPS_NAV_MEASURED_NAVIGATION MessageGPS_NAV_MEASURED_TRACKER identifier. See GPS_NAV_RAW_TRACKER chapter 7for GPS_NAV_SW_VERSION message GPS_NAV_CLOCK_STATUS details.GPS_NAV_50BPS_DATA GPS_NAV_ERROR GPS_NAV_ACK GPS_NAV_NAKGPS_NAV_VISIBLITY_LIST GPS_NAV_NL_MEAS_DATA GPS_NAV_NL_DGPS_DATAGPS_NAV_NL_SV_STATE_DATA GPS_NAV_NL_INIT_DATA GPS_ADC_ODOMETER_DATAGPS_NAV_COMPLETE GPS_NAV_TEXT message_structure 32 bit pointer Pointerto the message structure with data Length Varies depending on themessage bytes Length of the message structure

TABLE 23 Example #include “gps_types.h” #include “gps_interface.h”#include “gps_messages.h” void GPS_Output( tGPS_UINT32 message_id, void*message_structure, tGPS_UINT32 length ) {  tGPS_NAV_MEASURED_NAVIGATION nav_data;   switch ( message_id )   {    case GPS_NAV_MEASURED_NAVIGATION:       memcpy( &nav_data,message_structure, sizeof(tGPS_NAV_MEASURED_NAVIGATION) );       if (nav_data.nav_mode & GPS_MODE_MASK )         printf(“x=%ld, y=%ld, z=%ld\n”,         nav_data.ecef_x, nav_data.ecef_y,         nav_data.ecef_z);      else         printf(“no fix \n”);       break;     caseGPS_NAV_MEASURED_TRACKER:       // use tracker information here      break;   default:       break;   } // switch } // GPS_Output( )

The GPS_Input function sends a command to the GPS engine. The functionmay be called by the client program to send a command to the GPSreceiver.

TABLE 24 Include file gps_interface.h Syntax tGPS_UINT32 GPS_Input(tGPS_UINT32 message_id, void *message_structure, tGPS_UINT32 length )Parameter Data range Units Description message_id GPS_NAV_INITIALIZEMessage identifier. GPS_NAV_POLL_SW_VERSION See chapter 7 forGPS_NAV_SET_DGPS_SOURCE message details. GPS_NAV_SET_NAV_MODEGPS_NAV_SET_DOP_MODE GPS_NAV_SET_DGPS_MODE GPS_NAV_SET_ELEV_MASKGPS_NAV_SET_POWER_MASK GPS_NAV_SET_STAT_NAV GPS_NAV_POLL_CLOCK_STATUSGPS_NAV_POLL_RX_MGR_PARAMS GPS_NAV_SET_MSG_RATE GPS_NAV_SET_SBAS_PRNmessage_structure 32 bit pointer Pointer to the message structure withdata to send length Varies depending on the message bytes Length of themessage structure

TABLE 25 Return values Return value Description GPS_SUCCESS Message wassent successfully GPS_ERROR Error: Message was not acknowledgedGPS_ERROR_NOT_STARTED Error: GPS engine is not running

TABLE 26 Example #include “gps_types.h” #include “gps_interface.h”#include “gps_messages.h” /* Forces cold start of GPS receiver: */tGPS_NAV_INITIALIZE InitMsg; tGPS_UINT32 result; memset( &InitMsg, 0,sizeof(tGPS_NAV_INITIALIZE) ); InitMsg.restart_flags = GPS_RESTART_COLD;result = GPS_Input( GPS_NAV_INITIALIZE, (void*)&InitMsg,sizeof(tGPS_NAV_INITIALIZE) );

The GPS communication interface messages are exchanged between the GPSclient (e.g., a user program) and positioning or GPS engine via the userinterface input and output functions.

TABLE 27 Primary GPS output messages Message id value Message id macroDescription  2 (0x02) GPS_NAV_MEASURED_NAVIGATION Provides ECEFposition, velocity, GPS time, position status  4 (0x04)GPS_NAV_MEASURED_TRACKER Provides satellite status, azimuth, elevationand C/No information  6 (0x06) GPS_NAV_SW_VERSION Provides GPS enginesoftware version  7 (0x07) GPS_NAV_CLOCK_STATUS Provides current GPSclock status 10 (0x0A) GPS_NAV_ERROR Provides error information 45(0x2D) GPS_ADC_ODOMETER_DATA Provides ADC, odometer and GPIO values fromtracker 47 (0x2F) GPS_NAV_COMPLETE This message is sent as a last one inthe navigation cycle. Informs that navigation cycle is complete. 255(0xFF) GPS_NAV_TEXT Provides development text information

TABLE 28 Primary GPS input messages Message id value Message id macroDescription 128 (0x80) GPS_NAV_INITIALIZE Performs re-initialization ofthe GPS receiver: factory, cold, warm or hot restarts. 132 (0x84)GPS_NAV_POLL_SW_VERSION Asks for the GPS engine software version 133(0x85) GPS_NAV_SET_DGPS_SOURCE Sets differential correction source 144(0x90) GPS_NAV_POLL_CLOCK_STATUS Asks for the current GPS clock status170 (0xAA) GPS_NAV_SET_SBAS_PRN Sets SBAS (WAAS/EGNOS) PRN number

TABLE 29 Additional GPS output messages for development and debugprocess Message id value Message id macro Description  8 (0x08)GPS_NAV_50BPS_DATA Provides 50 bps subframe data 11 (0x0B) GPS_NAV_ACKCommand acknowledgment 12 (0x0C) GPS_NAV_NAK Command not acknowledgment13 (0x0D) GPS_NAV_VISIBLITY_LIST Provides current visibilty list 28(0x1C) GPS_NAV_NL_MEAS_DATA Provides navigation library measurement data29 (0x1D) GPS_NAV_NL_DGPS_DATA Provides navigation library differentialdata 30 (0x1E) GPS_NAV_NL_SV_STATE_DATA Provides navigation librarysatellite state data 31 (0x1F) GPS_NAV_NL_INIT_DATA Provides navigationlibrary initialization data

TABLE 30 Additional GPS input messages for development and debug processMessage id value Message id macro Description 136 (0x88)GPS_NAV_SET_NAV_MODE Sets navigation mode 137 (0x89)GPS_NAV_SET_DOP_MODE Sets DOP mask control mode 138 (0x8A)GPS_NAV_SET_DGPS_MODE Sets differential mode of operation 139 (0x8B)GPS_NAV_SET_ELEV_MASK Sets elevation mask 140 (0x8C)GPS_NAV_SET_POWER_MASK Sets power mask 143 (0x8F) GPS_NAV_SET_STAT_NAVConfigures static navigation mode 152 (0x98) GPS_NAV_POLL_RX_MGR_PARAMSAsks for current navigation parameters 166 (0xA6) GPS_NAV_SET_MSG_RATESets message output rate

The GPS_NAV_MEASURED_NAVIGATION output message provides ECEF position,velocity, GPS time and position status information. The message isoutputted periodically at 1 Hz rate:

TABLE 31   Include file   gps_messages.h Message id: Value Macro 2(0x02) GPS_NAV_MEASURED_NAVIGATION

TABLE 32 Message structure tGPS_NAV_MEASURED_NAVIGATION Data rangeStructure (after de- Scale member Data type scaling) factor UnitsDescription ecef_x SINT32 1 meters Computed ECEF ecef_y SINT32 1 metersposition. ecef_z SINT32 1 meters ecef_vel_x SINT16 0.125 m/sec ComputedECEF ecef_vel_y SINT16 0.125 m/sec velocity ecef_vel_z SINT16 0.125m/sec nav_mode UINT8 n/a n/a Navigation status flags. See below fordetails. hdop UINT8 0 . . . 50.0 0.2 n/a Horizontal Dilution OfPrecision nav_mode2 UINT8 n/a n/a Navigation status flags. See below fordetails. gps_week UINT16 >0 1 n/a Computed full GPS week number. gps_towUINT32 0 . . . 604799.99 0.01 sec. Computed GPS time of the week.sv_used_cnt UINT8 0 . . . 12 1 n/a Number of satellites used insolution. sv_used UINT8[12] 1 . . . 32 1 n/a Array of PRN numbers ofsatellites used in solution Note: To get a real value of the parameter avalue from the structure should be multiplied by the scale factor.

TABLE 33 nav_mode bit fields 7 6 5 4 3 2 1 0 DGPS DOP Altitude statusreserved 0 Position status status mask status

TABLE 34 Position status Value Macro Description 0 No navigationsolution 1 1 satellite degraded solution 2 2 satellites degradedsolution 3 3 satellites solution (2D) 4 More than 3 satellites solution(3D) 5 3 satellites least square solution (2D) 6 More than 3 satellitesleast square solution (3D) 7 Dead reckoning

TABLE 35 Altitude status Value Macro Description 0 No altitude hold 1Altitude used from filter 2 Altitude used from user 3 Forced altitude(from user)

TABLE 36 DOP mask status: Value Macro Description 0 DOP mask notexceeded 1 GPS_MODE_DOP_MASK_EXCEED DOP mask exceeded

TABLE 37 DGPS status: Value Macro Description 0 Differential correctionsare not used in solution 1 GPS_MODE_DGPS_USED Differential correctionsare used in solution

TABLE 38 nav_mode2 bit fields: 7 6 5 4 3 2 1 0 reserved reservedreserved reserved reserved DR timed Solution reserved out validationstatus

TABLE 39 Solution validation status: Value Macro Description 0 Solutionis not validated 1 GPS_MODE2_SOLUTION_VALIDATED Solution is validated

TABLE 40 DR timed out status: Value Macro Description 0 Dead reckoningnot timed out 1 GPS_MODE2_DR_TIMED_OUT Dead reckoning has timed out

The GPS_NAV_MEASURED_TRACKER output message provides satellite status,azimuth, elevation and C/No information. The message is outputtedperiodically at 1 Hz rate.

TABLE 41   Include file   gps_messages.h Message id: Value Macro 4(0x04) GPS_NAV_MEASURED_TRACKER

TABLE 42 Message Structure Message structure tGPS_NAV_MEASURED_TRACKERData range Structure (after de- Scale member Data type scaling) factorUnits Description gps_week UINT16 1 . . . 1 Computed full GPS weeknumber. gps_tow UINT32 0 . . . 604799.99 0.01 sec. Computed GPS time ofthe week. chnl_cnt UINT8 12 1 Number of receiver's channels chnltGPS_SV_INFO[12] Array of structures containing satellite informationfor each receiver channel. See below.

TABLE 43 tGPS_SV_INFO sub-structure: Data range Structure (after de-Scale member Data type scaling) factor Units Description svid UINT8 1 .. . 32 1 Satellite PRN number azimuth UINT8 0 . . . 359.5 1.5 deg.Satellite azimuth angle. elevation UINT8 0 . . . 90.0 0.5 deg Satelliteelevation angle state UINT16 n/a Satellite tracking status. See below.cno UINT8[10] 0 . . . 60 1 dB-Hz Array of satellite signal to noiseratios for the past second. Measurements are made every 100 ms. Value atindex zero is the oldest. Note: To get a real value of the parameter avalue from the structure should be multiplied by the scale factor.

TABLE 44 state bit fields: 15 14 13 12 11 10 9 8 reserved 0 reserved 0reserved 0 reserved 0 reserved 0 reserved 0 reserved 0 Initialacquisition in progress

TABLE 45 state bit fields: 7 6 5 4 3 2 1 0 Ephemeris Acquisition CodeCarrier Sub Bit Delta Acquisition data failed locked Pulling Frame syncdone Phase success available done sync done valid

The GPS_NAV_SW_VERSION output message provides a positioning enginesoftware version string. Message is sent as a reply to theGPS_NAV_POLL_SW_VERSION input message.

TABLE 46   Include file   gps_messages.h Message id: Value Macro 6(0x06) GPS_NAV_SW_VERSION

TABLE 47 Message structure tGPS_NAV_SW_VERSION Data range Data (afterde- Scale Structure member type scaling) factor Units Descriptionsw_version[100] UINT8 ASCII GPS engine characters software version.Version string is NULL terminated. Message length is variable but doesnot exceed 100 bytes.

The GPS_NAV_CLOCK_STATUS output message provides current GPS clockstatus information. Message is outputted periodically at 1 Hz rate or ondemand as a reply to GPS_NAV_POLL_CLOCK_STATUS input message.

TABLE 48   Include file   gps_messages.h Message id: Value Macro 7(0x07) GPS_NAV_CLOCK_STATUS

TABLE 49 Message structure tGPS_NAV_CLOCK_STATUS Structure Data Datarange Scale member type (after de-scaling) factor Units Descriptiongps_week UINT16 1 . . . 1 Computed full GPS week number. gps_tow UINT320 . . . 604799.99 0.01 sec Computed GPS time of the week. sv_used_cntUINT8 0 . . . 12 1 Number of satellites used in solution. clk_offsetUINT32 25000 . . . 146000 1 Hz Computed clock offset clk_bias UINT32 0 .. . 0.1 1e−9 sec Computed clock bias est_gps_time UINT32 0 . . .604799.999 0.001 sec Estimated GPS time Note: To get a real value of theparameter a value from the structure should be multiplied by the scalefactor.

The GPS_NAV_ERROR output message outputs notification, warning, andalert messages.

TABLE 50   Include file   gps_messages.h Message id: Value Macro 10(0x0A) GPS_NAV_ERROR

TABLE 51 Message structure tGPS_NAV_ERROR Structure Data Data rangeScale member type (after de-scaling) factor Description err_id UINT16 0. . . 0x0FFF n/a Notification code 0x1000 . . . 0x1FFF n/a Warning code0x2000 . . . 0x2FFF n/a Alert code param_cnt UINT16 0 . . . 5 1 Numberof 32-bit parameters in param[ ] param[5] UINT32 UINT32 range n/a Arrayof information parameters. Meaning depends on error code

The GPS_ADC_ODOMETER_DATA output message provides ADC, odometer and GPIOlines state from tracker. Message is outputted periodically at 1 or 10Hz rate depending on setting used in GPS_Start( ) function.

TABLE 52   Include file   gps_messages.h Message id: Value Macro 45(0x2D) GPS_ADC_ODOMETER_DATA

TABLE 53 Message structure tGPS_ADC_ODOMETER_DATA Data range StructureData (after de- Scale member type scaling) factor Units Descriptioncurrent_time UINT32 >=0 1 ms Tracker Time, millisecond counts fromtracker reset adc2_avg INT16 −8192 . . . 8191 1 n/a Averaged measurementfrom ADC[2] input. See below for voltage formula. adc3_avg INT16 −8192 .. . 8191 1 n/a Averaged measurement from ADC[3] input. See below forvoltage formula. odo_count UINT16 0 . . . 0xFFFF 1 n/a Odometer countermeasurement at the most recent 100 ms tracker input gpio_stat UINT8 0 .. . 0xFF n/a n/a GPIO input states at the most recent 100 ms trackerinput. Bit field, see below.

TABLE 54 gpio_stat bit field: 7 6 5 4 3 2 1 0 GPIO12 GPIO8 GPIO7 GPIO5GPIO4 GPIO3 GPIO2 GPIO0 input state input state input state input stateinput state input state input state input state

TABLE 55 GPIOxx state: Value Macro Description 0 Input pin xx is in lowstate 1 Input pin xx is in high state

In one implementation, the Voltage formula is Uin[V]=Vref*((adcX_avg+8192)/16384), where: Vref=2.55V, and adcX_avg is ameasurement value from message above. The analog to digital convertermay, for example, take measurements at 50 Hz rate and the reported valueadcX_avg may be an average of the last 5 samples.

The GPS_NAV_COMPLETE output message is sent at the end of the navigationcycle to confirm that the GPS engine has finished a position computationcycle (with or without success). In one implementation, this message isoutputted at 1 Hz rate.

TABLE 56   Include file   gps_messages.h Message id: Value Macro 47(0x2F) GPS_NAV_COMPLETE

TABLE 57 Message structure tGPS_NAV_COMPLETE Structure Data Data range(after Scale member type de-scaling) factor Units Description controlUINT8 0 Not in use.

The GPS_NAV_TEXT output message outputs debug and development messagesin text format.

TABLE 58   Include file   gps_messages.h Message id: Value Macro 255(0xFF) GPS_NAV_TEXT

TABLE 59 Message structure tGPS_NAV_TEXT Structure Data Data range Scalemember type (after de-scaling) factor Units Description msg_text[256]UINT8 ASCII Text of characters the message

The GPS_NAV_INITIALIZE input message performs GPS enginere-initialization. Message should be used to perform factory, cold, warmor hot restart.

TABLE 60   Include file   gps_messages.h Message id: Value Macro 128(0x80) GPS_NAV_INITIALIZE

TABLE 61 Message structure tGPS_NAV_INITIALIZE Structure Data Data range(before Scale member type scaling) factor Units Description ecef_xSINT32 1 meters Approximate ECEF ecef_y SINT32 1 meters position. Thosevalues ecef_z SINT32 1 meters are used by warm start with initializationonly. clk_offset SINT32 0, 25000 . . . 146000 1 Hz Default GPS clockoffset. This value is used by the factory re- start only. If zero isprovided here a default value of 96250 Hz is used. gps_tow UINT32 0 . .. 604799 1 sec. Approximate GPS time of the week. This value is used bywarm start with initialization only gps_week UINT16 0 . . . 1Approximate full GPS week number. This value is used by warm start withinitialization only. chnl_cnt UINT8 12 1 Number of channels to use.restart_flags UINT8 Restart configuration flags. See below for details.

TABLE 62 restart_flags bit fields: 7 6 5 4 3 2 1 0 reserved 0 reserved 0Enable reserved 0 Restart mode. See below text for allowed values.output

TABLE 63 Restart mode Value Macro Description 0 GPS_RESTART_HOT Hotrestart 2 GPS_RESTART_WARM_NOINIT Warm restart with no initialization 3GPS_RESTART_WARM_INIT Warm restart with initialization (fields ecef_x,ecef_y, ecef_z, gps_tow, gps_week are used) 6 GPS_RESTART_COLD Coldrestart 8 GPS_RESTART_FACTORY Factory restart Other Reserved value

TABLE 64 Enable text output: Value Macro Description 0 Development textoutput (messages GPS_NAV_TEXT) is disabled 1 GPS_RESTART_TEXTOUTDevelopment text output (messages GPS_NAV_TEXT) is enabled

In one implementation, the navigation engine will initiate restartwithin one second and a default clock offset value is 96250 Hz. When theactual clock offset is unknown a value of 96250 Hz should be used.However, if the real clock offset is far from a specified value a longerTTFF will be observed.

TABLE 65 Example #include “gps_types.h” #include “gps_interface.h” /*Forces cold start of GPS receiver: */ tGPS_NAV_INITIALIZE InitMsg;tGPS_UINT32 result; memset( &InitMsg, 0, sizeof(tGPS_NAV_INITIALIZE) );gps_init.chnl_cnt = 12; gps_init.restart_flags = GPS_RESTART_HOT |GPS_RESTART_TEXTOUT; result = GPS_Input( GPS_NAV_INITIALIZE,(void*)&InitMsg, sizeof(tGPS_NAV_INITIALIZE) );

The GPS_NAV_POLL_SW_VERSION input message asks for the software versionof the position/GPS library.

TABLE 66   Include file   gps_messages.h Message id: Value Macro 132(0x84) GPS_NAV_POLL_SW_VERSION

TABLE 67 Message structure tGPS_NAV_POLL_SW_VERSION Structure Data Datarange Scale member type (before scaling) factor Units Descriptioncontrol UINT8 0 Not in use.

The software version string may be returned, for example, in aGPS_NAV_SW_VERSION output message via GPS_Output( ) function.

The GPS_NAV_SET_DGPS_SOURCE input message selects a data source fordifferential (DGPS) corrections.

TABLE 68    Include file    gps_messages.h Message id: Value Macro 133(0x85) GPS_NAV_SET_DGPS_SOURCE

TABLE 69 Message structure tGPS_NAV_SET_DGPS_SOURCE Structure Data rangeScale member Data type (before scaling) factor Units Description srcUINT8 see below n/a n/a Selects differential correction data source.Default is NONE after factory reset. freq UINT32 0 Internal beaconfrequency. Not used, set to 0. bit_rate UINT8 0 Internal beacon bitrate. Not used, set to 0.

TABLE 70 Differential correction source: Value Macro Description 0GPS_DGPS_SRC_NONE Differential corrections are not used for navigation 1GPS_DGPS_SRC_SBAS Selects SBAS as a data source Other value Reserved

These settings may be saved in nonvolatile data storage.

The GPS_NAV_POLL_CLOCK_STATUS input message asks for the current GPSclock status of the GPS library.

TABLE 71    Include file    gps_messages.h Message id: Value Macro 144(0x90) GPS_NAV_POLL_CLOCK_STATUS

TABLE 72 Message structure tGPS_NAV_POLL_CLOCK_STATUS Structure DataData range Scale member type (before scaling) factor Units Descriptioncontrol UINT8 0 Not in use.

The clock status data may be returned in GPS_NAV_CLOCK_STATUS outputmessage via GPS_Output( ) function.

The GPS_NAV_SET_SBAS_PRN input message manually forces PRN for use inSBAS corrections.

TABLE 73    Include file    gps_messages.h Message id: Value Macro 170(0xAA) GPS_NAV_SET_SBAS_PRN

TABLE 74 Message structure tGPS_NAV_SET_DGPS_MODE Structure Data Datarange Scale member type (before scaling) factor Units Description prnUINT8 0, 120 . . . 138 1 PRN number, 0 = Automatic search reserved_0UINT32 Reserved reserved_1 UINT32 Reserved

These settings may be saved in permanent data storage.

The Operating System Interface functions are operating system dependentand are implemented in the open source format available from SiRFTechnology, Inc. The functions include Thread, mutex and semaphorefunctions. Permanent storage and RTC functions may be availabledepending on hardware availability.

TABLE 75 Thread control functions Function name Description Provided inOS_Thread_Create( ) Function creates a thread gps_rtos.cOS_Thread_Delete( ) Function deletes a thread gps_rtos.cOS_Thread_Sleep( ) Function suspends a thread for a gps_rtos.c giventime

TABLE 76 Mutex control functions Function name Description Provided inOS_Mutex_Create( ) Function creates a mutex object - gps_rtos.c asoftware critical section OS_Mutex_Delete( ) Function deletes a mutexobject gps_rtos.c OS_Mutex_Enter( ) Function obtains a mutex objectgps_rtos.c OS_Mutex_Exit( ) Function releases a mutex object gps_rtos.c

TABLE 77 Semaphore control functions Implemented Function nameDescription in OS_Semaphore_Create( ) Function creates a semaphoregps_rtos.c object OS_Semaphore_Delete( ) Function deletes a semaphoregps_rtos.c object OS_Semaphore_Wait( ) Function waits for a gps_rtos.csemaphore OS_Semaphore_Release( ) Functions releases a gps_rtos.csemaphore object

TABLE 78 Permanent storage control functions Function name DescriptionImplemented in OS_Storage_Open( ) Functions opens a storage gps_rtos.csystem OS_Storage_Close( ) Functions closes a storage gps_rtos.c systemOS_Storage_Write( ) Function writes given words gps_rtos.c to thenon-volatile storage area (battery backed RAM, file, registry, etc.)OS_Storage_WriteAll( ) Function writes all storage gps_rtos.c data tothe non-volatile storage area (battery backed RAM, file, registry, etc.)OS_Storage_Read( ) Function retrieves a data from gps_rtos.c thenon-volatile storage area

TABLE 79 Real Time Clock control function Function name DescriptionImplemented in OS_RTC_Read( ) Function returns a current time gps_rtos.cfrom on-board's real time clock.

The OS_Thread_Create( ) function uses an appropriate operating systemservice to create a thread. The function is called by the GPS engine atthe startup to create all desired threads.

TABLE 80    File    gps_rtos.c    Syntax    tGPS_UINT32OS_Thread_Create( tGPS_UINT32 thread_id,                  tGPS_HANDLEfunction_ptr,                  tGPS_THREAD *thread_handle ) ParameterData range Units Description thread_id Thread macros defined Identifierof the thread to in gps_rtos.h be created function_ptr Thread functionthread_handle Handle of the created thread

TABLE 81 Return values Return value Description GPS_SUCCESS Thread wascreated successfully GPS_RTOS_ERROR An error occurred

A maximum number of desired threads may be specified by aGPS_RTOS_THREAD_MAX define.

The OS_Thread_Delete( ) function uses appropriate OS service to stop athread and/or to wait for thread to gracefully stop. Function is calledby the GPS engine from GPS_Stop( ) to stop all SiRFNav threads.

TABLE 82 File gps_rtos.c Syntax    tGPS_UINT32OS_Thread_Delete(tGPS_THREAD    thread_handle, tGPS_UINT32 timeout )Parameter Data range Units Description thread_handle Thread handleTimeout ms Grace period allowed before terminating the thread

TABLE 83 Return values Return value Description GPS_SUCCESS Thread wasdeleted successfully GPS_RTOS_ERROR An error occurred

Thread identifiers and functions may be specified, for example, in thegps_rtos.h header file.

The OS_Thread_Sleep( ) function uses appropriate OS service to suspend athread for a given number of milliseconds. Function is called by the GPSengine to suspend current thread temporarily.

TABLE 84 File gps_rtos.c Syntax tGPS_UINT32 OS_Thread_Sleep (tGPS_UINT32milliseconds ) Parameter Data range Units Description Miliseconds msTime for what thread will be suspended

TABLE 85 Return values Return value Description GPS_SUCCESS Thread sleephas finished successfully

The OS_Mutex_Create( ) function uses an operating system service tocreate a Mutex (mutually exclusive) object, or OS-specific equivalentsuch as a software critical section. This function is called by the GPSengine at the startup to create all desired mutexes.

TABLE 86 File gps_rtos.c Syntax tGPS_UINT32 OS_Mutex_Create( tGPS_MUTEX*mx_handle ) Parameter Data range Units Description mx_handle Handle ofthe created mutex object

TABLE 87 Return values Return value Description GPS_SUCCESS Mutex wassuccessfully created GPS_RTOS_ERROR An error occurred

The maximum number of desired mutexes may be specified by aGPS_RTOS_MUTEX_MAX define.

The OS_Mutex_Delete( ) function uses an operating system service todelete a Mutex object. The function is called by the GPS engine at thestopping procedure to delete all used mutexes.

TABLE 88 File gps_rtos.c Syntax tGPS_UINT32 OS_Mutex_Delete( tGPS_MUTEXmx_handle ) Parameter Data range Units Description mx_handle Mutexobject handle

TABLE 89 Return values Return value Description GPS_SUCCESS Mutex wassuccessfully deleted GPS_RTOS_ERROR An error occurred

The OS_Mutex_Enter( ) function uses an operating system service toobtain a Mutex object. This function is called by the GPS engine justbefore entering into a critical section.

TABLE 90 File gps_rtos.c Syntax tGPS_UINT32 OS_Mutex_Enter( tGPS_MUTEXmx_handle ) Parameter Data range Units Description mx_handle Mutexobject handle

TABLE 91 Return values Return value Description GPS_SUCCESS Mutex wassuccessfully obtained GPS_RTOS_ERROR An error occurred

The OS_Mutex_Exit( ) function uses appropriate OS service to release aMutex object. Function is called by the GPS engine just after leavingfrom a critical section.

TABLE 92 File gps_rtos.c Syntax tGPS_UINT32 OS_Mutex_Exit( tGPS_MUTEXmx_handle ) Parameter Data range Units Description mx_handle Mutexobject handle

TABLE 93 Return values Return value Description GPS_SUCCESS Mutex wassuccessfully released GPS_RTOS_ERROR An error occurred

The OS_Semaphore_Create( ) function uses an operating system service tocreate a Semaphore object. The function is called by the GPS engine atthe startup to create all desired semaphores.

TABLE 94 File gps_rtos.c Syntax tGPS_UINT32 OS_Semaphore_Create(tGPS_SEMAPHORE *sem_handle, tGPS_UINT32 init_value ) Parameter Datarange Units Description sem_handle Handle of the created semaphoreobject init_value any UINT32 Semaphore initialization value

TABLE 95 Return values Return value Description GPS_SUCCESS Semaphorewas successfully created GPS_RTOS_ERROR An error occurred

The maximum number of desired semaphores may specified by aGPS_RTOS_SEM_MAX define.

The OS_Semaphore_Delete( ) function uses an operating system service todelete a Semaphore object. The function is called by the GPS engine atthe stopping procedure to delete all used semaphores.

TABLE 96 File gps_rtos.c Syntax tGPS_UINT32 OS_Semaphore_Delete(tGPS_SEMAPHORE sem_handle ) Parameter Data range Units Descriptionsem_handle Semaphore object handle

TABLE 97 Return values Return value Description GPS_SUCCESS Semaphorewas successfully deleted GPS_RTOS_ERROR An error occurred

The OS_Semaphore_Wait( ) function uses an operating system service towait for Semaphore object. Function is called by the GPS threads to waitfor events.

TABLE 98 File gps_rtos.c Syntax tGPS_UINT32 OS_Semaphore_Wait(tGPS_SEMAPHORE sem_handle, tGPS_UINT32 timeout ) Parameter Data rangeUnits Description sem_handle Semaphore object handle Timeout0-4000000000 or ms Maximum time allowed to wait GPS_INFINITE forsemaphore

TABLE 99 Return values Return value Description GPS_SUCCESS Semaphorewas successfully obtained GPS_RTOS_ERROR An error occurredGPS_RTOS_SEM_WAIT_TIMEOUT Waiting for the semaphore has timed out,semaphore was not obtained.

The OS_Semaphore_Release( ) function uses appropriate OS service torelease a Semaphore object. The function is called by the GPS engine toschedule other thread.

TABLE 100 File gps_rtos.c Syntax tGPS_UINT32 OS_Semaphore_Release(tGPS_SEMAPHORE sem_handle ) Parameter Data range Units Descriptionsem_handle Semaphore object handle

TABLE 101 Return values Return value Description GPS_SUCCESS Semaphorewas successfully released GPS_RTOS_ERROR An error occurred

The OS_Storage_Open( ) function uses an operating system or BIOS serviceto open a non volatile storage system. The function is called by the GPSengine at the startup to open a storage.

TABLE 102 File gps_rtos.c  Syntax  tGPS_RESULT OS_Storage_Open( void )Parameter Data range Units Description none

TABLE 103 Return values Return value Description GPS_SUCCESS Storage hasbeen opened successfully GPS_RTOS_ERROR An error occurred

When the nonvolatile storage is not available then function may returnGPS_RTOS_ERROR.

The OS_Storage_Close( ) function uses appropriate OS or BIOS service toclose a non volatile storage system. The function is called by the GPSengine at the shut down procedure to close a storage.

TABLE 104 File gps_rtos.c Syntax tGPS_RESULT OS_Storage_Close( void )Parameter Data range Units Description none

TABLE 105 Return values Return value Description GPS_SUCCESS Storage hasbeen closed successfully GPS_RTOS_ERROR An error occurred

When the nonvolatile storage is not available then function may returnGPS_RTOS_ERROR.

The OS_Storage_Write( ) function uses appropriate OS or BIOS service towrite given words to a non volatile storage system (battery backed RAM,file system, etc.). The function is called by the GPS engineperiodically, for example every 30 seconds, to save time, position andephemeris information. That information is used later to speed up theGPS start procedure (e.g., for hot or warm starts).

TABLE 106 File gps_rtos.c Syntax tGPS_RESULT OS_Storage_Write(tGPS_UINT32 offset, tGPS_UINT16 *data, tGPS_UINT16 words ) ParameterData range Units Description offset bytes Offset from the beginning ofthe storage structure where new data should be written data Pointer tothe data to write words 16 bit Number of 16 bit words to words write

TABLE 107 Return values Return value Description GPS_SUCCESS Write donesuccessfully GPS_RTOS_ERROR An error occurred

The OS_Storage_WriteAll( ) function uses an operating system or BIOSservice to write a GPS data structure to a nonvolatile storage system.The function is called by the GPS engine periodically, for example every30 seconds, to save time, position and ephemeris information. Thatinformation is used later to speed up the GPS start procedure (hot orwarm starts)

TABLE 108 File gps_rtos.c Syntax tGPS_RESULT OS_Storage_WriteAll(tGPS_UINT8 *data, tGPS_UINT16 length ) Parameter Data range UnitsDescription data Pointer to the data to write length bytes Length of thedata

TABLE 109 Return values Return value Description GPS_SUCCESS Write donesuccessfully GPS_RTOS_ERROR An error occurred

The OS_Storage_Read( ) function uses an operating system or BIOS serviceto read GPS data structure from a nonvolatile storage system. Thefunction is called by the GPS engine at the startup to retrieve time,position and ephemeris information. This information is used to speed upthe GPS start procedure (e.g., for hot or warm starts).

TABLE 110 File gps_rtos.c Syntax tGPS_RESULT OS_Storage_Read( tGPS_UINT8*data, tGPS_UINT16 words ) Parameter Data range Units Description dataPointer to the data to read words 16 bit Length of the data words

TABLE 111 Return values Return value Description GPS_SUCCESS Read donesuccessfully GPS_RTOS_ERROR An error occurred

The OS_RTC_Read( ) function uses an operating system or BIOS service toread a real time clock information from the host's RTC. The function iscalled periodically by the GPS engine.

TABLE 112 File gps_rtos.c Syntax tGPS_UINT32 OS_RTC_Read( tGPS_UINT16*weekno, tGPS_UINT32 *timeOfWeek ) Parameter Data range UnitsDescription weekno 1 .. GPS full week number timeOfWeek 0 .. 604799999ms GPS time of the week

TABLE 113 Return values Return value Description GPS_SUCCESS Read donesuccessfully GPS_RTOS_ERROR An error occurred

The tracker communication interface functions allow messages to be sentand received between the tracker hardware and the user programs andposition library.

TABLE 114 tracker communication interface functions Function DescriptionImplemented in GPS_COMM_TRK_Create( ) Creates tracker gps_comm_trk.cinterface port handle GPS_COMM_TRK_Delete( ) Deletes trackergps_comm_trk.c interface port handle GPS_COMM_TRK_Open( ) Opens andgps_comm_trk.c configures tracker port GPS_COMM_TRK_Reopen( ) Reopensand/or gps_comm_trk.c reconfigures tracker port GPS_COMM_TRK_Close( )Closes tracker port gps_comm_trk.c GPS_COMM_TRK_Wait( ) Waits for datafrom gps_comm_trk.c the tracker GPS_COMM_TRK_Read( ) Reads data from thegps_comm_trk.c tracker GPS_COMM_TRK_Write( ) Send commands togps_comm_trk.c the tracker

The GPS_COMM_TRK_Create( ) function uses an OS or BIOS service to createa tracker communication handle. The function is called by the GPS engineat the startup to create a communication handle.

TABLE 115 File gps_comm_trk.c Syntax tGPS_UINT32 GPS_COMM_TRK_Create(tGPS_COMM *port_handle ) Parameter Data range Units Descriptionport_handle Pointer to the communication port handle

TABLE 116 Return values Return value Description GPS_SUCCESS Port handlewas successfully created GPS_COMM_ERROR Error creating port handle

The GPS_COMM_TRK_Delete( ) function uses an OS or BIOS service to deletea tracker communication handle. The function is called by the GPS engineat the stopping procedure to delete a communication handler.

TABLE 117 File   gps_comm_trk.c   Syntax   tGPS_UINT32GPS_COMM_TRK_Delete( tGPS_COMM   port_handle ) Parameter Data rangeUnits Description port_handle Pointer to the communication port handle

TABLE 118 Return values Return value Description GPS_SUCCESS Port handlewas successfully deleted GPS_COMM_ERROR An error occurred while deletingport handle

The GPS_COMM_TRK_Open( ) function uses an OS or BIOS service to open andconfigure a tracker communication port. The function is called by theGPS engine at the startup.

TABLE 119 File gps_comm_trk.c Syntax tGPS_UINT32 GPS_COMM_TRK_Open(tGPS_COMM port_handle, tGPS_UINT32 port_num, tGPS_UINT32 baud_rate )Parameter Data range Units Description port_handle Pointer to thecommunication port handle port_num Specifies a communication port wheretracker is connected to. 1 = serial port 1, 2 = serial port 2, . . .baud_rate 4800, 38400, bps Specifies a baud rate at which tracker 57600,is connected to. Default 2t tracker 115200 baud rate is 38400 bps.

TABLE 120 Return values Return value Description GPS_SUCCESS Port wassuccessfully opened GPS_COMM_ERROR An error occurred while opening orconfiguring the port

The GPS_COMM_TRK_Reopen( ) function uses an OS or BIOS service tore-open a tracker communication port. The function is called by the GPSengine after coming back from a power suspend mode. When power suspendmode is not required then the function may return GPS_SUCCESS only.

TABLE 121 File gps_comm_trk.c Syntax tGPS_UINT32 GPS_COMM_TRK_Reopen(tGPS_COMM port_handle ) Parameter Data range Units Descriptionport_handle Pointer to the communication port handle

TABLE 122 Return values Return value Description GPS_SUCCESS Port wassuccessfully re-opened GPS_COMM_ERROR An error occurred

The GPS_COMM_TRK_Close( ) function uses an OS or BIOS service to close atracker communication port. The function is called by the GPS engine atthe stopping procedure to close the port.

TABLE 123 File gps_comm_trk.c Syntax tGPS_UINT32 GPS_COMM_TRK_Close(tGPS_COMM port_handle ) Parameter Data range Units Descriptionport_handle Pointer to the communication port handle

TABLE 124 Return values Return value Description GPS_SUCCESS Port wassuccessfully closed GPS_COMM_ERROR An error occurred

The GPS_COMM_TRK_Wait( ) function uses an OS or BIOS services to waitfor data from a tracker communication port. The function is called bythe GPS engine to wait for the tracker data.

TABLE 125 File gps_comm_trk.c Syntax tGPS_UINT32 GPS_COMM_TRK_Wait(tGPS_COMM port_handle, tGPS_UINT32 timeout ) Parameter Data range UnitsDescription port_handle Pointer to the communication port handle timeout0-4000000000 or ms Timeout value GPS_INFINITE

TABLE 126 Return values Return value Description GPS_SUCCESS Data fromtracker is available GPS_COMM_DATA_NOT_AVAILABLE Error: data fromtracker was not available within given time

The GPS_COMM_TRK_Read( ) function uses appropriate OS or BIOS servicesto read data from a tracker communication port. The function is calledby the GPS engine to read tracker data.

TABLE 127   File   gps_comm_trk.c Syntax   tGPS_UINT32GPS_COMM_Trk_Read(tGPS_COMM   port_handle,         tGPS_UINT8 *data,        tGPS_UINT32 length,         tGPS_UINT32 *bytes_read ) ParameterData range Units Description port_handle Pointer to the communicationport handle data Pointer to the read data length 1 . . . 65535 bytesNumber of requested bytes bytes_read 0 . . . length bytes Number ofbytes read

TABLE 128 Return values Return value Description GPS_SUCCESS Data readwas successful GPS_COMM_DATA_NOT_AVAILABLE An error occurred

The GPS_COMM_TRK_Write( ) function uses appropriate OS or BIOS servicesto write data to the tracker communication port. The function is calledby the GPS engine to send commands to the tracker hardware.

TABLE 129 File gps_comm_trk.c Syntax tGPS_UINT32 GPS_COMM_Trk_Write(tGPS_COMM port_handle, tGPS_UINT8 *data, tGPS_UINT32 length ) ParameterData range Units Description port_handle Pointer to the communicationport handle data Pointer to the data to send length 1 . . . 65535 bytesNumber of bytes to send

TABLE 130 Return values Return value Description GPS_SUCCESS Data writewas successful GPS_COMM_ERROR An error occurred

Turning next to FIG. 5, that figure shows a block diagram 500 of theCooperation between threads, tasks and hardware in one implementation ofa host based GPS solution. In particular, the tracker hardware 104communicates through a serial driver 502 (for example, the Windows CEserial driver). The serial driver 502 communicates and cooperates with afile system 504 (for example, the Windows CE file system), whichincludes input buffers and output buffers for the communications thatwill occur.

FIG. 5 shows a pass through data flow path to the tracker hardware 104.The path includes the SendPasahroughDataToTracker thread 506 thatforwards data directly from a client program, through a pass throughcontrol function 508 to a tracker interface send function 510. In thereception direction, the tracker interface receive function 512 forwardsdata from the tracker hardware 104 to the navigation/positioning enginequeue 514 (if the message is destined for the positioning engine), or tothe user interface queue 516 (if the message is destined directly forthe user program). The DataForwarder thread 518 removes messages fromthe user interface queue 516 and sends them via the user callbackfunction 520 to the user program. When the host 102 includes theComponent Object Module interface (available from Microsoft), the usercallback function 520 may be the IcallBack function.

The receive manager and navigation thread 522 removes messages destinedfor the GPS library from the positioning engine queue 514, and alsoplaces messages destined for the user programs on the user interfacequeue 516. The messages for the GPS library are processed by the tasksincluding the NavPeriodicTask 524. A set of shared buffers, controlflags, completion flags, and the like 526 are maintained by the GPSlibrary. Finally, it is noted that the COM interface provides a set ofcontrol functions 528.

Turning next to FIG. 6, that figure illustrates one execution schedule600 for the receive manager thread 522 and the NavPeriodicTask 524. Inthe schedule 600, the NavPeriodicTask 524 runs as a low-priority(background) thread, while the receiver manager and navigation thread522 run in one normal-priority thread.

With regard to FIG. 7, that figure shows a synchronization diagram 700.The synchronization diagram 700 illustrates the timing and interactionbetween the threads and tasks shown in FIG. 5.

With reference to FIG. 7, receive manager (RxM) and navigation (Nav) runsequentially in one loop that waits for new data from Tracker Interface(TRK_IF) Receiver before each iteration. Either RxM or Nav may signalsNavPeriodicTask 524 to proceed with one iteration of its loop (unlessNavPeriodicTask 524 already performing its task, in which case it willfinish the task and skip one loop).

The RxM and Nav thread 522 may wait on a Critical Section when writingdata to the UI Queue 516, or when sending data to Tracker 104. Therewill typically be a thread running while RxM&Nav are waiting. In oneimplementation, NavPeriodicTasks 524 runs at smaller priority than theother tasks and it will not run as long as any other thread is running.In an alternative implementation, NavPeriodicTasks 524 runs at normalpriority, but does not present a conflict as long as RxM&Nav havesufficient priority to consume data generated by NavPeriodicTasks 524.

The RxM and Nav thread 522 runs the RxM control task that maintains astate machine for the Rx and manages the state machine transitions basedon current state. The RxM communicates with the tracker hardware 104through the tracker interface. It both sends data and commands to thetracker hardware 104 to pace it through initial acquisition and trackingof SPS satellites, and receives data and status messages from thereceiver with raw SPS satellite tracking data. The primary purpose ofthe RxM task is to manage and control the operation of the trackerhardware 104. It also preprocesses the raw tracker data and submits theprocessed data to the Navigation Processing Task. The RxM gets scheduledor called by the Nav Task once the tracker hardware 104 starts tracking.

The NavPeriodicTasks thread 524 is a pseudo task that performsmiscellaneous support operations for the RxM and Nav tasks. Itsfunctions include determining and performing updates to the satellitestate tables, and generating new visible SPS satellite list when newephemeris data is collected, or whenever it is requested.

The Nav Processor Thread performs position, velocity and timecomputations based on the RxM generated individual SPS satellite data.This makes use of the functionality offered through the navigationlibrary in optimally computing the navigation position data. Thecomputed navigation data is made available to the Data Forwardingthread. At the beginning of each iteration, the Nay Processor calls orschedules the RxM task to run, and then it performs navigationcomputations and generates the user position, velocity, and time data.Based on the computation results, if pre-selected error thresholds areexceeded, the Nay Processor may send commands to the receiver, eitherdirectly or through the RxM, to force the receiver to reset.

The I/O Reader thread and Tracker Interface Receiver 512 sends data toqueues as shown in FIG. 5. In addition, data length error checks may beperformed with error counts logged in a global variable. Erroneousmessage bytes will be reported to the user program through debugmessages.

Note that in some implementations, the I/O Writer thread 510 is notused. Instead, its role may been taken by TRK_IF, whose methods areinvoked from the RxM+Nav thread 522 and SendPassThruDataToTracker 504.TRK_IF writes directly to the serial port. (All I/O functions will begrouped into one class). In WinCE, buffering is performed on the FileSystem level, which allows TRK_IF to return quickly upon sending data.On Nucleus, additional buffering may be provided.

The DataForwarderThread 518 reads from the UI Queue 516 and calls theuser program's ICallBack interface for each binary message to be sent.If the UI queue's Semaphore is still signaled after Callback returns,the DataForwarderThread 518 may continue piping data until the UI queue516 is empty. In one implementation, the UI Queue 516 is not lockedwhile Callback is being executed, which allows other threads to runwhile waiting for Callback to return. Client Callback typically putsdata in internal storage for another thread to use. Generally, oneCallback is called at a time. The UI Queue 516 is prioritized and itwill put pass-thru messages before all others in the queue.

The SendPassThruDataToTracker function 506 is an API call for sendingpass-thru messages from the user program to the tracker hardware 104.Note that the pass through control function 504 may be implemented as afilter to enable or disable pass-thru messages:

A Shutdown may be performed by purging all queues and I/O. For example,300 ms (enough for RxM&Nav to complete) may then be given for threads tocomplete. Although some threads may not complete in that time, such asthe DataForwarderThread 518 (that may be waiting for Callback toreturn), and NavPeriodicTask 524, for which there may or may not be aprovision to interrupt long-term calculations. Regardless, threads whichdo not complete on time are terminated.

The following synchronization objects may be used: a Semaphore andCritical Section in UI Queue 516 for triggering UI output, a Semaphoreand Critical Section in Trk2Nav Queue 514 for triggering Nav update, aPositioning/Navigation Library sync flag (from NavPeriodTasks to RxM andNav), and a shutdown semaphore and flag. Note that the CriticalSection(s) in the Tracker Interface are for protecting access to theserial port.

Queues may have the following API and features: Constructor/destructor,void *GetBuffer(int priority, long size) to obtain a pre-allocated,buffer for Put( ) void Put( ) to queues the buffer with specifiedpriority, void *BeginGet° to waits until data ready or shutdown, voidEndGet( ), void Remove( ), void Purge( ) to cancel all BeginGet calls,an internal Semaphore for notifying BeginGet( ) when data is ready, andan internal Critical Section.

With regard to error checking, all queue overruns, I/O errors, timeoutsand COM errors may optionally be reported to client, packaged in debugmessages, UI queue 516 overruns will be reported as an error to userprogram, Tracker message time-outs may be handled by Nav, and Trk2NavQueue 514 overruns may be signaled to RxM and Nay.

It is further noted that the Windows registry may provide a mechanismfor configuring thread priorities (that may, for example, be set once atstartup and remain unchanged during execution), I/O buffer sizes, andqueue sizes. Note that the SetupComm( ) function may be used to increasethe size of existing WinCE I/O buffers. Doing so prevents input dataloss under stress conditions. This may also be configurable throughregistry, and default values may be chosen to accommodate severalseconds of I/O (e.g., 4 kb for input and 1 kb for output).

The foregoing description of an implementation of the invention has beenpresented for purposes of illustration and description. It is notexhaustive and does not limit the invention to the precise formdisclosed. Modifications and variations are possible in light of theabove teachings or may be acquired from practicing of the invention. Forexample, the described implementation includes software but the presentinvention may be implemented as a combination of hardware and softwareor in hardware alone. Note also that the implementation may vary betweensystems. The invention may be implemented with both object-oriented andnon-object-oriented programming systems. The claims and theirequivalents define the scope of the invention.

1. A system for processing positioning signals, the system comprising: amobile phone including: a tracker hardware interface for receivingpositioning information from a tracker hardware internal or external tothe mobile phone; a memory including a GPS library having a userinterface, a tracker interface, and an operating system interface, thetracker interface including at least one tracker interface function forcommunicating with the tracker hardware over the tracker hardwareinterface; and a processor for running the tracker interface function,wherein the processor, using the GPS library, computes a location of themobile phone based on the positioning information obtained by thetracker interface function, and is configured to communicate thelocation of the mobile phone to a plurality of respectively differentuser programs running on the mobile phone in response to requests fromthe respective programs.
 2. The system of claim 1, wherein the trackerhardware interface comprises a serial interface.
 3. The system of claim1, wherein the user interface comprises at least one positioning controlfunction and at least one positioning engine communication function. 4.The system of claim 3, wherein the positioning control functioncomprises a positioning engine start function.
 5. The system of claim 3,wherein the positioning control function comprises a positioning enginestop function.
 6. The system of claim 3, wherein the positioning enginecommunication function is a command delivery function.
 7. The system ofclaim 1, wherein the user programs includes at least one of: a mappingprogram displaying the location of the mobile phone, a course charterprogram displaying a path traveled by the mobile phone and a locationaid program displaying location information of the mobile phone.